<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    #container {
      /*整个高度*/
      height: 100vh;
      display: flex;
      text-align: center;
      /*垂直排列 这样可以不用设置宽度(不设置也行)*/
      flex-direction: column;
      justify-content: space-between;
    }

    .header {
      height: 80px;
      line-height: 80px;
      background-color: #2b669a;
    }

    .main {
      /*自动膨胀 占满区域*/
      flex-grow: 1;
      height: 10px;
      margin: 5px 0;
      line-height: 500px;
      background-color: #4cae4c;
    }

    .footer {
      height: 100px;
      line-height: 100px;
      background-color: #c7254e;
    }
  </style>
</head>
<body>
<div id="container">
  <div class="header">1</div>
  <div class="main">
    <div>2</div>
  </div>
  <div class="footer">3</div>
</div>
</body>
</html>
